package com.zf.rocketmq.consumer.listener;

import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.annotation.SelectorType;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * 消费 plain_text_topic_tag，使用Tag过滤消息，之消费满足条件的消息。
 * 这里消费 tag 为 t1、t3 或者 t5 的消息
 */
@Component
@RocketMQMessageListener(consumerGroup = "spring_plain_text_tag_cg", topic = "plain_text_topic_tag",
        selectorType = SelectorType.TAG, selectorExpression = "t1 || t3 || t5")
public class ConsumerPlanTextWithTagMsgListener implements RocketMQListener<String> {
    /**
     * 该方法由 RocketMQListener 接口提供，用来消费消息。
     */
    @Override
    public void onMessage(String message) {
        System.out.printf("plain_text_tag：%s\n", message);
    }

}
